//
//  HTAccountModel.swift
//  weibo
//
//  Created by JonsonLiu on 16/4/19.
//  Copyright © 2016年 liujonson. All rights reserved.
//

import UIKit

class HTAccountModel: NSObject {
    
    var uid: String?
    // 过期时间
    // -[__NSCFNumber length] - unrecognized selector sent to instance 0xb000000000229c43'
    // 代表属性的类型写错啦。把 Int 写成 String 了
    var expires_in: Int = 0
        
//        NSTimeInterval = 0{
//        //    var expires_in: String?  --> 会崩溃
//        didSet{
//            expiresDate = NSDate(timeIntervalSinceNow: expires_in)
//        }
//    }
    var access_token: String?
    
    var remind_in: String?
    
    var name: String?
    // 用户头像地址（大图），180×180像素
    var avatar_large: String?
    
    var expiresDate: NSDate?
    
    
    
    init(dict : [String : AnyObject]){
        
        super.init()
        
        setValuesForKeys(dict)
    }
    
    
//    // MARK: - 实现协议的方法
//    // 解档 --> 如何读取
//    required init?(coder decoder: NSCoder) {
//        uid = decoder.decodeObjectForKey("uid") as? String
//        expires_in = decoder.decodeDoubleForKey("expires_in")
//        access_token = decoder.decodeObjectForKey("access_token") as? String
//        remind_in = decoder.decodeObjectForKey("remind_in") as? String
//        name = decoder.decodeObjectForKey("name") as? String
//        avatar_large = decoder.decodeObjectForKey("avatar_large") as? String
//        expiresDate = decoder.decodeObjectForKey("expiresDate") as? NSDate
//    }
//    
//    // 归档要调用的方法 --> 如何保存
//    func encodeWithCoder(encoder: NSCoder) {
//        encoder.encodeObject(uid, forKey: "uid")
//        encoder.encodeDouble(expires_in, forKey: "expires_in")
//        encoder.encodeObject(access_token, forKey: "access_token")
//        encoder.encodeObject(remind_in, forKey: "remind_in")
//        encoder.encodeObject(name, forKey: "name")
//        encoder.encodeObject(avatar_large, forKey: "avatar_large")
//        encoder.encodeObject(expiresDate,forKey: "expiresDate")
//    }
    
}
